#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H

#include <QObject>

class QNetworkAccessManager;
class QNetworkRequest;

class HttpRequest : public QObject
{
    Q_OBJECT
public:
    static QString m_scheme;
    static QString m_serverAddr;
    static QString m_port;
    static QString m_requestHeader;
    static QHash<QString, QString> m_receive_data;
    static QVariantMap m_map_post;
    static QVariantMap m_map_get;


public:
    explicit HttpRequest(QObject *parent, QString scheme, QString serverAddr, QString port);

    explicit HttpRequest(QObject *parent, const QString& url);

    HttpRequest(const HttpRequest &hr);

    HttpRequest &operator=(const HttpRequest &hr);

    ~HttpRequest();

    static QString scheme();
    static void setScheme(const QString &scheme);

    static QString serverAddr();
    static void setServerAddr(const QString &serverAddr);

    static QString port();
    static void setPort(const QString &port);

    static QString requestHeader();
    static void setRequestHeader(const QString &requestHeader);

    void setNetworkManager(QNetworkAccessManager *manager);
    QNetworkAccessManager *getNetworkManager() const;

    static QHash<QString, QString> getReceive_data();
    static void setReceive_data(const QHash<QString, QString> &receive_data);


    static QVariantMap getMap_post();
    static void setMap_post(const QVariantMap &map_post);

    static QVariantMap getMap_get();
    static void setMap_get(const QVariantMap &map_get);

public:

    int NormalGetRequest(QString path, const QMap<QString, QString> &keyValuePairs);

    int NormalPostRequest(QString path, const QMap<QString, QString> &keyValuePairs);

    int PostRequestWithFile(QString paramer1, QString paramer2,QString filePath);


    int DownloadFileFromWeb(QString fileUrl, QString &fileSavePath);


    //    int sendRequest(const QNetworkRequest &request);
    void uploadFile(const QString &fileName, const QString &url);
    HttpRequest(QObject *parent, const HttpRequest &hr);


signals:

private slots:

    void do_RequestFinished();

private:
    QString m_url;
    QNetworkAccessManager* m_networkManager;

};

#endif // HTTPREQUEST_H
